import _ from 'lodash';

const state = {
  resizeStatus: '', // 窗体是否活动 客户端和浏览器都试用 (new Date()).valueOf()

  needGetOcrResult: false, //是否需要获取OCR结果
  needShowActiveOcrText: false, //是否需要高亮显示Ocr结果和图片中的区域
  needRefreshList: false, //是否需要刷新文件列表
  loading: false, //判断是否正在上传
  imgResult: false, //判断图片是否加载结束
  ocrResult: false, //判断ocr是否识别结束

  screenShotsStatus: false, // 判断是否截图
  screenKeyStatus: 0, // 是否快捷键截图 0默认状态 1快捷键启动截图 2esc取消截图

  fileSearchVisible: false, // 搜索弹窗的展示隐藏
  selectionBtnVisible: false, // 拖动选择的按钮展示隐藏

  loadingLabel: '', // 正在上传的提示语

  screenInputChar: '', // 快捷键
  screenCanUse: false, // 快捷键是否冲突
  
  editMode: false, // 是否是编辑模式
  tableExit: false, // 是否有表格

  captureVisible: false, // 截图下拉列表是否展示
  exportVisible: false, // 导出下拉列表是否展示
  qaVisible: false, // 问题反馈下拉

  advancedFunStatus: 0, // 0系统配置不允许使用高级功能，高级功能按钮也不展示 1系统配置可以使用高级功能，有高级功能，但是没点击开启，示例文件夹和操作栏不出现 2可以使用，点击开启
  advancedFunButtonStatus: 0, // 0未开启高级功能，1开启歪斜校正，2开启图像切边，3开启分栏切分，4开启签章去干扰
  advancedFunImgSrc: '', // 高级功能 引擎处理后的图片地址
  advancedFunOcrStatus: 0, // 0不启用任何识别接口查询功能 1启用歪斜校正后查询功能 2图像切边 3图像切边 4签章 5表格识别

  imgRotateAngle: 0, // 从后端获取的图片需要旋转的角度
  imgRotateAngleSrc: '', // 旋转后的新图片

  fileDownloadVisible: false, // 导出列表展示隐藏
  fileDownloadList: [], // 当前正在导出的文件列表
  fileDownloadfileIds: [], // 当前在导出的文件，不能刷新、编辑、删除、重命名
  fileDownloadAnimation: [ { status: false, startTop: '0px', startLeft: '12px', }, ],// status：导出动画状态，在点击导出成功的那一秒为 true 一秒后重置为false 起点位置的top left { status: false, startTop: '0px', startLeft: '12px', },

  fileEdit: 0, // 0默认状态 1文件刚编辑/刚开启高级功能 2关闭
}

const getters = {}

const actions = {}

const mutations = {
  setResizeStatus(state, resizeStatus) {
    state.resizeStatus = resizeStatus
  },
  setNeedGetOcrResult(state, needGetOcrResult = false) {
    state.needGetOcrResult = needGetOcrResult
  },
  setNeedShowActiveOcrText(state, needShowActiveOcrText = false) {
    state.needShowActiveOcrText = needShowActiveOcrText
  },
  setNeedRefreshList(state, needRefreshList) {
    state.needRefreshList = needRefreshList
  },
  setFileLoadingState(state, loading) {
    state.loading = loading
  },
  setImgInfo(state, imgResult) {
    state.imgResult = imgResult
  },
  setOcrInfo(state, ocrResult) {
    state.ocrResult = ocrResult
  },
  setScreenShotsStatus(state, screenShotsStatus) {
    state.screenShotsStatus = screenShotsStatus
  },
  setScreenKeyStatus(state, screenKeyStatus) {
    state.screenKeyStatus = screenKeyStatus
  },
  setFileSearchVisible(state, fileSearchVisible) {
    state.fileSearchVisible = fileSearchVisible
  },
  setSelectionBtnVisible(state, selectionBtnVisible) {
    state.selectionBtnVisible = selectionBtnVisible
  },
  setLoadingLabel(state, loadingLabel) {
    state.loadingLabel = loadingLabel
  },
  setScreenInputChar(state, screenInputChar) {
    state.screenInputChar = screenInputChar
  },
  setScreenCanUse(state, screenCanUse) {
    state.screenCanUse = screenCanUse
  },
  setEditMode(state, editMode) {
      state.editMode = editMode;
  },
  setTableExit(state, tableExit) {
      state.tableExit = tableExit;
  },
  setCaptureVisible(state, captureVisible) {
    state.captureVisible = captureVisible;
  },
  setExportVisible(state, exportVisible) {
    state.exportVisible = exportVisible;
  },
  setQaVisible(state, qaVisible) {
    state.qaVisible = qaVisible;
  },
  setAdvancedFunStatus(state, advancedFunStatus) {
    state.advancedFunStatus = advancedFunStatus;
  },
  setAdvancedFunButtonStatus(state, advancedFunButtonStatus) {
    state.advancedFunButtonStatus = advancedFunButtonStatus;
  },
  setAdvancedFunImgSrc(state, advancedFunImgSrc) {
    state.advancedFunImgSrc = advancedFunImgSrc;
  },
  setAdvancedFunOcrStatus(state, advancedFunOcrStatus) {
    state.advancedFunOcrStatus = advancedFunOcrStatus;
  },
  setImgRotateAngle(state, imgRotateAngle) {
    state.imgRotateAngle = imgRotateAngle;
  },
  setImgRotateAngleSrc(state, imgRotateAngleSrc) {
    state.imgRotateAngleSrc = imgRotateAngleSrc;
  },
  setFileDownloadVisible(state, fileDownloadVisible) {
    state.fileDownloadVisible = fileDownloadVisible;
  },
  setFileDownloadList(state, fileDownloadList) {
    if( !_.isEqual(state.fileDownloadList, fileDownloadList) ){
      // console.log('setFileDownloadList', fileDownloadList);
      state.fileDownloadList = fileDownloadList;
    }
    //
  },
  setFileDownloadfileIds(state, fileDownloadfileIds) {
    state.fileDownloadfileIds = fileDownloadfileIds;
  },
  setFileDownloadAnimation(state, fileDownloadAnimation) {
    state.fileDownloadAnimation = fileDownloadAnimation;
  },
  setFileEdit(state, fileEdit) {
    state.fileEdit = fileEdit;
  },
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations,
}
